package left42dead;

/**
 * Represents a shotgun weapon item that the humans can pick up
 */
public class Shotgun extends Weapon
{
    private static final int MAX_AMMO = 7;

    /**
     * Create a shotgun with the given ammo count
     * @param ammo Initial ammo count
     */
    public Shotgun (int ammo)
    {
        super(ammo);
    }

    /**
     * Use the shotgun to shoot another character
     */
    public void use (Character target)
    {
        if (!isOutOfAmmo())
        {
            if (target instanceof Zombie)
            {
                Zombie zombie = ((Zombie) target);
                zombie.setStunned();
                zombie.reduceHealthPoints(20);
                ammo--;
            }
            // In this game, we decided that shotgun have effects on vampire too
            else if (target instanceof Vampire)
            {
                Vampire vampire = ((Vampire) target);
                vampire.reduceHealthPoints(60);
                ammo--;
            }
        }
    }

    /**
     * Reload the shotgun with the ammo
     */
    public void reload (Ammo bullets)
    {
        if (bullets.getAmount() > MAX_AMMO)
        {
            this.setAmmo(MAX_AMMO);
        }
        else
        {
            this.setAmmo(bullets.getAmount());
        }
    }
}
